package comment.service.impl;


import article.entity.ArticleVO;
import blogData.entity.BlogDataVO;
import comment.dao.CommentDao;
import comment.entity.CommentVO;
import comment.service.CommentService;
import generic.page.Pages;

public class CommentServiceImpl implements CommentService{

    private CommentDao commentDao;

    public void setCommentDao(CommentDao commentDao) {
        this.commentDao = commentDao;
    }

    @Override
    public CommentVO findCommentVOById(Integer commentId) {
        return this.commentDao.findCommentVOById(commentId);
    }

    @Override
    public void deleteCommentById(Integer commentId) {
        this.commentDao.deleteCommentById(commentId);
    }

    @Override
    public CommentVO addCommentVO(CommentVO commentVO, BlogDataVO blogDataVO, ArticleVO articleVO) {
        blogDataVO.getCommentVOs().add(commentVO);
        articleVO.getCommentVOs().add(commentVO);

        commentVO.setArticleVO(articleVO);
        commentVO.setBlogDataVO(blogDataVO);

        return   this.commentDao.addCommentVO(commentVO);
    }

    @Override
    public Pages queryPageByArticle(Pages pages, Integer articleId) {
        return this.commentDao.queryPageByArticle(pages, articleId);

    }

    @Override
    public Pages queryPageByBlogData(Pages pages, Integer blogDataId) {
        if(pages==null){
            pages=new Pages();
        }
        return this.commentDao.queryPageByBlogData(pages,blogDataId);

    }
}
